import Vue from 'vue';
import store from '../store';

import {
  getRegisterInfo,
  getAboutInfo, getQAInfo, getSiteMapInfo,
  getPortalInfo, getHomeData,
  getPolicies, getOnePolicy,
  getStandards, getOneStandard,
  getStdOrgs, getOneStdOrg,
  getDatasets, getOneDataset,
  getTools, getOneTool,
  getServices, getOneService,
  getNews, getOneNews,
  getCases, getOneCase,
  getSolutions, getOneSolution,
  globalSearch,
  getTests, getOneTestResult,
  getAnnouncements, getOneAnnouncement,
  getFeedbacks,
  industryEvals,
  industryEvalsResults,
  getOneIndustryEval,
  olTrainings, getOneOlTraining,
  achievements, getOneAchievement,
  consults, getOneconsult,
  basicinfo, getOneBasicinfo,
  reports, getOneReport,
  getCommitteeData,
  getCommitteeInfo,
  getCommitteeFields,
} from './api';

const bus = new Vue({ store });

export default {
  register: () => ({
    GetData: () => getRegisterInfo().then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
    Bus: bus,
  }),
  portal: () => ({
    GetData: () => getPortalInfo().then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
    Bus: bus,
  }),
  about: () => ({
    GetData: () => getAboutInfo().then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
  }),
  sitemap: () => ({
    GetData: () => getSiteMapInfo().then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
    Bus: bus,
  }),
  qa: () => ({
    GetData: () => getQAInfo().then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
  }),
  home: () => ({
    GetData: () => getHomeData().then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
    Bus: bus,
  }),
  policies: () => ({
    autoGet: false,
    GetData: (q) => getPolicies({ ...q }).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
    Bus: bus,
  }),
  policyDetails: (route) => ({
    GetData: () => getOnePolicy(route.params.id).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
  }),
  standards: () => ({
    autoGet: false,
    GetData: (q) => getStandards(q).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
    Bus: bus,
  }),
  standardDetails: (route) => ({
    GetData: () => getOneStandard(route.params.id).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
  }),
  stdorgs: () => ({
    autoGet: false,
    GetData: (q) => getStdOrgs(q).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
    Bus: bus,
  }),
  stdorgDetails: (route) => ({
    GetData: () => getOneStdOrg(route.params.id).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
  }),
  datasets: () => ({
    autoGet: false,
    GetData: (q) => getDatasets(q).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
    Bus: bus,
  }),
  datasetDetails: (route) => ({
    GetData: () => getOneDataset(route.params.id).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
  }),
  tools: () => ({
    GetData: (q) => getTools(q).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
    Bus: bus,
  }),
  toolDetails: (route) => ({
    GetData: () => getOneTool(route.params.id).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
  }),
  news: () => ({
    autoGet: false,
    GetData: (q) => getNews(q).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
    Bus: bus,
  }),
  newsDetails: (route) => ({
    GetData: () => getOneNews(route.params.id).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
  }),
  solutions: () => ({
    GetData: (q) => getSolutions(q).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
    Bus: bus,
  }),
  solutionDetails: (route) => ({
    GetData: () => getOneSolution(route.params.id).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
  }),
  cases: () => ({
    GetData: (q) => getCases(q).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
    Bus: bus,
  }),
  caseDetails: (route) => ({
    GetData: () => getOneCase(route.params.id).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
  }),
  announcements: () => ({
    autoGet: false,
    GetData: (q) => getAnnouncements(q).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
    Bus: bus,
  }),
  announcementDetails: (route) => ({
    GetData: () => getOneAnnouncement(route.params.id).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
  }),
  tests: () => ({
    GetData: (q) => getTests(q).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
  }),
  testResult: (route) => ({
    GetData: () => getOneTestResult(route.params.id).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
  }),
  services: () => ({
    GetData: (q) => getServices(q).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
    Bus: bus,
  }),
  serviceDetails: (route) => ({
    GetData: () => getOneService(route.params.id).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
  }),
  feedback: () => ({
    GetData: (q) => getFeedbacks(q).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
    Bus: bus,
  }),
  industryEval: () => ({
    autoGet: false,
    GetData: (q) => industryEvals(q).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
    Bus: bus,
  }),
  evalResults: () => ({
    GetData: (q) => industryEvalsResults(q).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
    Bus: bus,
  }),
  industryEvalDetail: (route) => ({
    GetData: () => getOneIndustryEval(route.params.id).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
  }),
  olTraining: () => ({
    autoGet: false,
    GetData: (q) => olTrainings(q).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
    Bus: bus,
  }),
  olTrainingDetail: (route) => ({
    GetData: () => getOneOlTraining(route.params.id).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
  }),
  achievement: () => ({
    autoGet: false,
    GetData: (q) => achievements(q).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
    Bus: bus,
  }),
  achievementDetail: (route) => ({
    GetData: () => getOneAchievement(route.params.id).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
  }),
  consult: () => ({
    autoGet: false,
    GetData: (q) => consults(q).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
    Bus: bus,
  }),
  consultDetail: (route) => ({
    GetData: () => getOneconsult(route.params.id).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
  }),
  basicinfo: () => ({
    autoGet: false,
    GetData: (q) => basicinfo(q).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
    Bus: bus,
  }),
  basicinfoDetail: (route) => ({
    GetData: () => getOneBasicinfo(route.params.id).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
  }),
  reports: () => ({
    autoGet: false,
    GetData: (q) => reports(q).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
    Bus: bus,
  }),
  reportDetail: (route) => ({
    GetData: () => getOneReport(route.params.id).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
  }),
  search: () => ({
    GetData: (q) => globalSearch(q).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
    Bus: bus,
  }),
  committee: () => ({
    GetData: () => getCommitteeData().then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
    Bus: bus,
  }),
  committeeInfo: (route) => ({
    GetData: (q) => getCommitteeInfo({ ...q, id: route.params.id }).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
    Bus: bus,
  }),
  joinCommittee: (route) => ({
    GetData: (q) => getCommitteeFields({ ...q, id: route.params.id }).then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
    Bus: bus,
  }),

  oltest: () => ({
    GetData: () => getVMs().then((d) => {
      const data = (d && d.data) || {};

      return data;
    }),
  }),
};
